<template>
    <!-- 修改资料 -->
    <div>
        <!-- 内容主题区域 -->
        <el-form label-width="120px" :model="form" label-position="right" ref="formRef" :rules="formRules" class="borderNone" disabled>
            <el-row>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                    <el-form-item label="数据库表名" prop="number">
                        <el-input  v-model="form.number" placeholder="请输入数据库表名"></el-input>&nbsp;
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                    <el-form-item label="表描述" prop="name">
                        <el-input v-model="form.name" placeholder="请输入表描述"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                    <el-form-item label="映射实体名" prop="entityName">
                        <el-input v-model="form.entityName"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                    <el-form-item label="表主键" prop="primaryFieldName">
                        <el-input v-model="form.primaryFieldName"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                    <el-form-item label="记录唯一字段" prop="uniqueFields">
                        <el-input v-model="form.uniqueFields"/>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                    <el-form-item label="是否自增型主键" prop="sautoIncreasePrimary">
                        <el-switch v-model="form.autoIncreasePrimary" active-value="true" inactive-value="false">
                        </el-switch>
                    </el-form-item>
                </el-col>
            </el-row>
            <sc-title title="表字段列表"></sc-title>
            <el-scrollbar height="400px">
                    <sc-form-table v-model="dataList" disabled placeholder="暂无数据">
                        <template #tableContent>
                            <el-table-column prop="number" label="字段名">
                            </el-table-column>
                            <el-table-column prop="name" label="字段描述">
                            </el-table-column>
                            <el-table-column prop="fieldTypeName" label="字段描述">
                            </el-table-column>
                            <el-table-column prop="refMainTableName" label="关联主表名">
                            </el-table-column>
                            <el-table-column prop="refMainTableFieldName" label="关联主表字段">
                            </el-table-column>
                            <el-table-column prop="lng" label="字段长度">
                            </el-table-column>
                            <el-table-column prop="scale" label="小数位数">
                            </el-table-column>
                            <el-table-column prop="nullable" label="是否可为空">
                                <template #default="scope">
                                    <el-switch v-model="scope.row.nullable" disabled> 
                                    </el-switch>
                                </template>
                            </el-table-column>
                            <el-table-column prop="autoIncrement" label="是否自增型">
                                <template #default="scope">
                                    <el-switch v-model="scope.row.autoIncrement" disabled>
                                    </el-switch>
                                </template>
                            </el-table-column>
                            <el-table-column prop="autoIncrement" label="是否导入">
              <template #default="scope">
                <el-switch v-model="scope.row.importFlag" disabled/>
              </template>
            </el-table-column>
                            <el-table-column prop="defaultValue" label="默认值">
                            </el-table-column>
                        </template>
                    </sc-form-table>
            </el-scrollbar>
        </el-form>
        <div class="button-position">
            <el-button @click="updateVisible">取 消</el-button>
        </div>
    </div>
</template>

<script setup>
import { reactive, ref, onMounted } from 'vue';
import { ElNotification } from 'element-plus';
import { Check, Close } from '@element-plus/icons-vue';
import Api from '@/api/model/meta'
const emit = defineEmits(['updatetable'])
const props = defineProps({
    paramsData: {
        type: Object,
        defalut: {}
    }
})

// 添加用户数据的对象
const form = ref({});
const dataList = ref([])
const formRef = ref()

onMounted(() => {
    getInit()
})

const getInit = async () => {
    let formRes = await Api.table.detail.post(props.paramsData)
    if (formRes.code == 200) {
        form.value = formRes.data
        dataList.value = formRes.dataList
    }
    console.log(dataList.value )
}


const updateVisible = (val) => {
    emit('updatetable')
}



</script>

<style lang="less" scoped>
.borderNone {
    :deep(.el-input__wrapper) {
        box-shadow: 0 0 0 0px var(--el-input-border-color, var(--el-border-color)) inset;
        cursor: default;
        background-color: transparent; //背景颜色透明
        border-bottom: 1px solid #999;
        border-radius: 0;

        .el-input__inner {
            cursor: default !important;
        }
    }
}
</style>

